<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 商务合作接口
 */
class Cooperation extends Api
{
    // 无需登录的接口,*表示全部
    protected $noNeedLogin = ['*'];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];

    //商务合作banner
    public function businessBanner(){
        $list = db('business_banner')->where('status','normal')->select();

        $this->success('',$list);
    }

    //合作厂商
    public function businessManufacturer(){
        $list = db('business_manufacturer')->where('status','normal')->select();

        $this->success('',$list);
    }

    //常见问题
    public function businessQuestion(){
        $list = db('business_question')->where('status','normal')->select();

        $this->success('',$list);
    }

    //操作说明
    public function businessExplain(){
        $list = db('business_explain')->where('status','normal')->select();

        $this->success('',$list);
    }

    //常见问题详情
    public function businessQuestionDetails(){
        $id = input('param.id');
        $info = db('business_question')->where('id',$id)->where('status','normal')->find();

        $this->success('',$info);
    }

    //操作说明详情
    public function businessExplainDetails(){
        $id = input('param.id');
        $info = db('business_explain')->where('id',$id)->where('status','normal')->find();

        $this->success('',$info);
    }

    //申请留言
    public function leavingMessage(){
        if(request()->isPost()){
            $data['cooperation_type'] = input('param.cooperation_type');
            $data['name'] = input('param.name');
            $data['phone'] = input('param.phone');
            $data['message'] = input('param.message');
            $data['createtime'] = time();

            $result = db('leaving_message')->insert($data);
            if($result){
                $this->success('留言成功');
            }else{
                $this->error('留言失败');
            }
        }
    }







}
